<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app"></div>
    <script src="vue.js"></script>
    <script>

        var sons={
            template:`
            <div>i am son</div>
            `,
            created:function(){
                console.log(this.$parent);
            }
        }

        var parent={
            template:
            `<div>i am parent
                <slot name='son'></slot>
                <sons ref='son'></sons>
            </div>`
            ,

            components:{
              sons,
            },

            mounted:function(){
                console.log(this.$refs.son);

            }
        };

        new Vue({
            el:'#app',

            components:{

                parent
            }
            ,

            template:`
                <div>
                    <parent>
                        <div>i am son1</div>  
                        <div slot='son'>i am son2</div> 
                    </parent>
                </div>
            
            `,

        })


    </script>
    
</body>
</html>